import { defineStore } from "pinia"

const mainStore = defineStore("user", {
    id:'user',
    state(){
        return {
            userData:[],//用户数据
            userDataById:[],//根据用户查询的数据
            searchVipCardById:[],//根据用户id查询会员卡信息
            userId:"",

        }
    },
    persist: {
        enabled: true, // 开启持久化保存
    },
    actions: {
        setUserData(userData:Array<any>){
            // console.log("进入Userstore");  
            this.userData = userData
            //  console.log("数据存储成功",this.userData);
        },
        setUserDataById(userDataById:Array<any>){
            // console.log("进入UserstoreById");  
            this.userDataById = userDataById
            //  console.log("数据存储成功",this.userDataById);
        },
        setSearchVipCardById(searchVipCardById:Array<any>){
            // console.log("进入UserstoreById");  
            this.searchVipCardById = searchVipCardById
            //  console.log("数据存储成功",this.searchVipCardById);
        },
        setUserd(userId:any){
            // console.log("进入UserstoreById");  
            this.userId = userId
            //  console.log("数据存储成功",this.userId);
        },
    },
    getters: {
        getUserDta():Array<any>{
            // console.log("进入getUserstore");
            return this.userData
        },
        getUserDtaById():Array<any>{
            // console.log("进入getUserstoreById");
            console.log("获取数据",this.userDataById);
            return this.userDataById
        },
        getSearchVipCardById():Array<any>{
            console.log("进入getUserstoreById");
            console.log("获取数据",this.searchVipCardById);
            return this.searchVipCardById
        },
        getUserId():any{
            // console.log("进入getUserstoreById");
            console.log("获取数据",this.userId);
            return this.userId
        },
    }
})


export default mainStore;